package engine

import "gitee.com/kinwyb/workflow/storage"

// FlowNodeType 数据节点类型
type FlowNodeType int

const (
	NodeTypeNormal FlowNodeType = iota //常规节点
	NodeTypeStart                      //开始节点
	NodeTypeEnd                        //停止节点
	NodeTypeRoute                      //判断节点
)

type FlowRoute struct {
	RouteID  string       `description:"公式ID"`
	ParentID string       `description:"父数据ID"`
	Formula  string       `description:"公式解析(eg. a=b|a>b|a<b|a>=b|a<=b|a)"`
	ActType  string       `description:"连接符号(eg. and|or)"`
	Desc     string       `description:"完整公式描述"`
	Children []*FlowRoute `description:"子判断"`
}

// Flow 流
type Flow struct {
	NodeID      string       `description:"节点ID"`
	NodeCode    string       `description:"节点编码"`
	NodeName    string       `description:"节点名称"`
	NodeType    FlowNodeType `description:"节点类型"`
	UserGroupID string       `description:"数据用户组"`
	Route       *FlowRoute   `description:"条件判断(类型为判断节点时有效)" json:",omitempty"`
	RouteDesc   string       `description:"条件描述" json:",omitempty"`
	RouteID     string       `description:"条件判断ID" json:",omitempty"`
	RouteSucc   *Flow        `description:"判断正确路径(类型为判断节点时有效)" json:",omitempty"`
	RouteFail   *Flow        `description:"判断失败路径(类型为判断节点时有效)" json:",omitempty"`
	Child       *Flow        `description:"子节点" json:",omitempty"`
}

type WorkCreateReq struct {
	WorkFlowCode string `description:"工作编码"`
	WorkName     string `description:"工作名称"`
	ExtendVal1   string `description:"扩展字段1"`
	ExtendVal2   string `description:"扩展字段2"`
	ExtendVal3   string `description:"扩展字段3"`
	ExtendVal4   string `description:"扩展字段4"`
	ExtendVal5   string `description:"扩展字段5"`
	Data         string `description:"工作数据的json内容"`
}

type Node struct {
	storage.Node
	Route *FlowRoute `description:"条件判断(类型为判断节点时有效)" json:",omitempty"`
}

type WorkNode struct {
	storage.WorkNode
	Route *FlowRoute `description:"条件判断(类型为判断节点时有效)" json:",omitempty"`
}
